package com.example.day08.homework;

public class StringEncryptJiesecret {

    public static void main(String[] args) {
        System.out.println(Encryption("abc"));
        System.out.println(Decryption("EFD"));
    }
    public static String Encryption(String str){
        StringBuilder stringBuilder=new StringBuilder(str);
        for (int i = 0; i <str.length() ; i++) {
            if(i+1==str.length()){
                stringBuilder.setCharAt(i,(char) (str.charAt(0)+(char)3));
                return stringBuilder.toString().toUpperCase();
            }
            stringBuilder.setCharAt(i, (char) (str.charAt(i+1)+(char)3));

        }
        return stringBuilder.toString().toUpperCase();
    }
    public static String Decryption(String str){
        StringBuilder stringBuilder=new StringBuilder(str);
        for (int i = 0; i <str.length() ; i++) {
            if(i+1==str.length()){
                stringBuilder.setCharAt(0,(char) (str.charAt(str.length()-1)-(char)3));
                return stringBuilder.toString().toLowerCase();
            }
            stringBuilder.setCharAt(i+1, (char) (str.charAt(i)-(char)3));

        }
        return stringBuilder.toString().toLowerCase();
    }


}
